/**
 * 对话泡泡
 * @param radio 画布大小比例
 * @param color 颜色
 * @returns 数据地址
 */
const DialogueImage = (radio?: number, color?: string) => {
    const r = radio || 1;
    const col = color || '#ffffff';
    const canvas = document.createElement('canvas');
    canvas.width = canvas.height = 40 * r;
    const ctx = canvas.getContext('2d')!;

    ctx.save();
    ctx.miterLimit=4;
    ctx.fillStyle=col;
    ctx.scale(0.035,0.035);
    ctx.save();
    ctx.scale(1,-1);
    ctx.translate(50*r,-1100*r);
    ctx.beginPath();
    ctx.moveTo(512*r,64*r);
    ctx.bezierCurveTo(794.77*r,64*r,1024*r,250.25*r,1024*r,480*r);
    ctx.bezierCurveTo(1024*r,709.752*r,794.77*r,896*r,512*r,896*r);
    ctx.bezierCurveTo(484.844*r,896*r,458.19*r,894.266*r,432.176*r,890.956*r);
    ctx.bezierCurveTo(322.198*r,1000.934*r,190.926*r,1020.656*r,64*r,1023.552*r);
    ctx.lineTo(64*r,996.636*r);
    ctx.bezierCurveTo(132.536*r,963.058*r,192*r,901.896*r,192*r,832*r);
    ctx.bezierCurveTo(192*r,822.246*r,191.242*r,812.67*r,189.836*r,803.304*r);
    ctx.bezierCurveTo(74.04*r,727.04*r,0,610.55*r,0,480*r);
    ctx.bezierCurveTo(0,250.25*r,229.23*r,64*r,512*r,64*r);
    ctx.closePath();
    ctx.moveTo(194.886*r,391*r);
    ctx.bezierCurveTo(149.598*r,391*r,112.886*r,427.712*r,112.886*r,473*r);
    ctx.bezierCurveTo(112.886*r,518.288*r,149.598*r,555*r,194.886*r,555*r);
    ctx.bezierCurveTo(240.17399999999998*r,555*r,276.88599999999997*r,518.288*r,276.88599999999997*r,473*r);
    ctx.bezierCurveTo(276.88599999999997*r,427.712*r,240.172*r,391*r,194.886*r,391*r);
    ctx.closePath();
    ctx.moveTo(512*r,391*r);
    ctx.bezierCurveTo(466.712*r,391*r,430*r,427.712*r,430*r,473*r);
    ctx.bezierCurveTo(430*r,518.288*r,466.712*r,555*r,512*r,555*r);
    ctx.bezierCurveTo(557.288*r,555*r,594*r,518.288*r,594*r,473*r);
    ctx.bezierCurveTo(594*r,427.712*r,557.288*r,391*r,512*r,391*r);
    ctx.closePath();
    ctx.moveTo(849.482*r,391*r);
    ctx.bezierCurveTo(804.194*r,391*r,767.482*r,427.712*r,767.482*r,473*r);
    ctx.bezierCurveTo(767.482*r,518.288*r,804.194*r,555*r,849.482*r,555*r);
    ctx.bezierCurveTo(894.77*r,555*r,931.482*r,518.288*r,931.482*r,473*r);
    ctx.bezierCurveTo(931.482*r,427.712*r,894.77*r,391*r,849.482*r,391*r);
    ctx.closePath();
    ctx.fill();
    ctx.stroke();
    ctx.restore();

    return canvas.toDataURL('image/png');
}


export { DialogueImage };